using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 检测类，用玩家角色检测场景中的信息
/// </summary>
public class PlayerDetection : MonoBehaviour
{
    public bool IsCanAirJumo { get; set; }
    [Header("地面检测")]
    [SerializeField] private Vector2 groundDetectionLeft;            // 玩家地面检测位置  左侧
    [SerializeField] private Vector2 groundDetectionRight;           // 玩家地面检测位置  右侧
    [SerializeField] private float groundDetectionRadius;            // 地面检测半径
    [SerializeField] private LayerMask groundLayerMask;              // 地面检测层
    


    private bool isGroundDetection => 
        (Physics2D.OverlapCircle(new Vector2(transform.position.x+groundDetectionLeft.x*transform.localScale.x,transform.position.y+groundDetectionLeft.y), 
             groundDetectionRadius, groundLayerMask) 
         || Physics2D.OverlapCircle(new Vector2(transform.position.x+groundDetectionRight.x*transform.localScale.x,transform.position.y+groundDetectionRight.y), 
             groundDetectionRadius, groundLayerMask));
    public bool GetIsGround
    {
        get { return isGroundDetection; }
    }
    
    
    //
    // void OnDrawGizmosSelected()
    // {
    //     // 仅当对象被选中时绘制 Gizmos
    //     DrawGroundDetectionCircle(groundDetectionLeft, Color.red);
    //     DrawGroundDetectionCircle(groundDetectionRight, Color.green);
    // }
    //
    // // 绘制地面检测圆的辅助方法
    // void DrawGroundDetectionCircle(Vector2 detectionOffset, Color color)
    // {
    //     // 计算圆的中心位置
    //     Vector3 center = transform.position + new Vector3(detectionOffset.x * transform.localScale.x, detectionOffset.y, 0f);
    //
    //     // 绘制圆
    //     Gizmos.color = color;
    //     Gizmos.DrawSphere(center, groundDetectionRadius);
    // }


}
